import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt

def face_detect_demo(src):
    face_detector = cv.CascadeClassifier('./haarcascades/haarcascade_frontalface_alt_tree.xml')
    gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)

    faces = face_detector.detectMultiScale(gray, 1.02, 5)

    for x, y, w, h in faces:
        cv.rectangle(src, (x, y), (x + w, y + h), (0, 0, 255), thickness=2)

    cv.imshow('result', src)


src = cv.imread('assets/img/00.jpg')

face_detect_demo(src)

cv.waitKey(0)

cv.destroyAllWindows()